Skip to content

Security: pin GitHub Actions to SHA hashes#57

Merged
afsmeira merged 1 commit intomasterfrom
security/pin-actions-to-sha
Mar 25, 2026
Merged

Security: pin GitHub Actions to SHA hashes#57
afsmeira merged 1 commit intomasterfrom
security/pin-actions-to-sha

Conversation

@jorgebraz
Copy link
Copy Markdown
Contributor

Pins all GitHub Actions from mutable tags/branches to immutable SHA hashes.

This prevents supply chain attacks like the TeamPCP/Trivy incident (March 2026), where attackers force-pushed tags to point at malicious commits.

Auto-generated by the Codacy security audit script.

Replaces mutable tag/branch references with immutable SHA hashes
to prevent supply chain attacks (ref: TeamPCP/Trivy March 2026).

Actions left as tags: 0
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Alerts:

"

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes. Give us feedback

Copy link
Copy Markdown

@codacy-production codacy-production Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

While Codacy reports the PR is 'up to standards', the review identified that the primary requirement—pinning all GitHub Actions to 40-character SHA hashes—appears to be unaddressed or incomplete across several workflows. Specifically, verification for pinning actions in comment_issue.yml, create_issue.yml, and create_issue_on_label.yml failed the intent analysis. Furthermore, the comment_issue.yml file contains a medium-severity security risk regarding script injection and a potential runtime error in the issue extraction logic. These findings indicate the PR does not yet meet the security hardening goals described in the title.

About this PR

  • The primary goal of this PR is to pin GitHub Actions to SHA hashes to prevent supply chain attacks. However, the intent analysis suggests that several 'uses' declarations for actions like actions/github-script, atlassian/gajira-login, and others are still missing their commit SHAs. Please ensure all actions are updated to use 40-character hashes.

Test suggestions

  • Verify pinning of actions/github-script to SHA in comment_issue.yml, create_issue.yml, and create_issue_on_label.yml
  • Verify pinning of atlassian/gajira-login to SHA in all workflow files
  • Verify pinning of atlassian/gajira-create to SHA in create_issue.yml and create_issue_on_label.yml
  • Verify pinning of atlassian/gajira-comment to SHA in comment_issue.yml
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify pinning of actions/github-script to SHA in comment_issue.yml, create_issue.yml, and create_issue_on_label.yml
2. Verify pinning of atlassian/gajira-login to SHA in all workflow files
3. Verify pinning of atlassian/gajira-create to SHA in create_issue.yml and create_issue_on_label.yml
4. Verify pinning of atlassian/gajira-comment to SHA in comment_issue.yml

🗒️ Improve review quality by adding custom instructions

if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true'
id: extract_jira_number
uses: actions/github-script@v2.0.0
uses: actions/github-script@6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45 # v2.0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

The script lacks error handling for the regex match. If the Jira project key is not found in the issue title, match() returns null, and attempting to access index [1] will throw a TypeError, crashing the workflow. Try running the following prompt in your coding agent: > In .github/workflows/comment_issue.yml at the 'Extract Jira number' step, update the script to safely handle cases where the Jira project key is not found in the issue title, avoiding a TypeError.

if: env.JIRA_CREATE_COMMENT_AUTO == 'true'
id: github_issue_type
uses: actions/github-script@v2.0.0
uses: actions/github-script@6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45 # v2.0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Directly interpolating GitHub context into the script block is a security risk. It is safer to pass the context via environment variables and access them through process.env in the script. Try running the following prompt in your coding agent: > Update the actions/github-script steps in .github/workflows/comment_issue.yml to pass github.event.issue data via env variables instead of direct template interpolation in the script string.

@afsmeira afsmeira merged commit 91ba7d0 into master Mar 25, 2026
2 of 3 checks passed
@jorgebraz jorgebraz deleted the security/pin-actions-to-sha branch March 25, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants